package com.gullmall.search.controller;

import com.gullmall.search.entity.vo.SearchParams;
import com.gullmall.search.entity.vo.SearchResult;
import com.gullmall.search.service.MallSearchService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;


@Controller
public class SearchController {

    @Resource(name = "mallSearchServiceImpl")
    private MallSearchService mallSearchService;


    @GetMapping({"/", "/index", "/list.html"})
    public String index(SearchParams searchParams, Model model) {
        System.out.println(searchParams);
        SearchResult searchResult = mallSearchService.search(searchParams);
        model.addAttribute("result",searchResult);
        return "list";
    }

}
